import fetch from '@/utils/fetch';

export function getList(query) {
    query._ts = (new Date()).getTime();
    return fetch({
        url: '/operator/audio/list',
        method: 'get',
        params: query
    });
}

export function getDetail(audioId) {
    var _ts = (new Date()).getTime();
    return fetch({
        url: '/operator/audio/detail',
        method: 'get',
        params: {
            audioId,
            _ts
        }
    });
}

export function add(audio) {
    return fetch({
        url: '/operator/audio/add',
        method: 'post',
        data: audio
    });
}

export function update(audio) {
    return fetch({
        url: '/operator/audio/update',
        method: 'post',
        data: audio
    });
}

export function toggleStatus(audioId, status) {
    return fetch({
        url: '/operator/audio/status/toggle',
        method: 'post',
        data: {
            audioId,
            status
        }
    });
}

export function toggleFree(audioId, free) {
    return fetch({
        url: '/operator/audio/free/toggle',
        method: 'post',
        data: {
            audioId,
            free
        }
    });
}


export function getPlayUrl(orgAudioUrl) {
    return fetch({
        url: '/operator/audio/play/url',
        method: 'get',
        params: {
            orgAudioUrl
        }
    });
}

export function updateSerial(courseId, audioId, serial) {
    return fetch({
        url: '/operator/audio/serial/update',
        method: 'post',
        data: {
            courseId,
            audioId,
            serial
        }
    });
}
